using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BattleManager : MonoBehaviour
{
    public static BattleManager Instance;
  
    public LinkedList<Boid> boidList = new LinkedList<Boid>();
    MapUtil map;

    private void Awake()
    {
        Instance = this;
        foreach (var item in FindObjectsOfType<Boid>())
            boidList.AddLast(item);
    }
    private void Start()
    {
        map = MapUtil.Instance;
    }
    public void UpdateMap()
    {
        map.Clear();
        foreach (var item in boidList)
        {
            map.JoinMap(item);
        }
    }

    void Update()
    {
        Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        pos.z = 0f;
        transform.position = pos;
    }
    float time;
    private void FixedUpdate()
    {
        time += Time.deltaTime;
        if (time < 1f / BattleConfig.frame)
        {
            return;
        }
        else
        {
            UpdateMap();
            time = 0f;
        }
    }

}
